import { Module } from '@nestjs/common';
import { Connection } from 'mongoose';
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose';
import { AuthModule } from '@/auth/auth.module';
import { MulterModule } from '@nestjs/platform-express';
import { UtilController } from './utils.controller';
import { CustomLoggerProvider } from '@/common/provider/logger.provider';
import configuration from '@/config/configuration';
import { UtilService } from './utils.servece';
import { Work, WorkSchema } from '@/work/schemas/work.schema';

@Module({
  imports: [
    MongooseModule.forFeatureAsync([
      {
        name: Work.name,
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        useFactory: (connection: Connection) => {
          return WorkSchema;
        },
        inject: [getConnectionToken()],
      },
    ]),
    AuthModule,
    MulterModule.register({
      dest: configuration().upload.dest,
    }),
  ],
  providers: [UtilService, CustomLoggerProvider, Connection],
  controllers: [UtilController],
  exports: [UtilService],
})
export class UtilsModule {}
